cmake_minimum_required(VERSION 3.14)
project(libshmpy)
set(CMAKE_CXX_STANDARD 20)
set(THIRD_PARTY_DIR ${PROJECT_SOURCE_DIR}/third_party)

add_subdirectory(${THIRD_PARTY_DIR}/pybind11)
add_subdirectory(${THIRD_PARTY_DIR}/fmt EXCLUDE_FROM_ALL)
add_subdirectory(${THIRD_PARTY_DIR}/spdlog)
add_subdirectory(${THIRD_PARTY_DIR}/catch2)


add_library(shmpy SHARED ${PROJECT_SOURCE_DIR}/src/wrapper.cxx)
target_include_directories(
    shmpy
    PUBLIC 
    ${PROJECT_SOURCE_DIR}/include/core 
    ${PROJECT_SOURCE_DIR}/include/mem
)

target_link_libraries(
    shmpy
    PUBLIC 
    pybind11::module
    pybind11::embed
    fmt::fmt-header-only
    spdlog::spdlog_header_only
    pthread
)
pybind11_extension(shmpy)
pybind11_strip(shmpy)

add_executable(TestCase_ShmObj ${PROJECT_SOURCE_DIR}/tests/Test_ShmObj.cxx)
target_include_directories(
    TestCase_ShmObj
    PRIVATE
    ${PROJECT_SOURCE_DIR}/include/core 
)
target_compile_options(
    TestCase_ShmObj
    PRIVATE
    "-O0"
    "-g"
)
target_link_libraries(
    TestCase_ShmObj
    PRIVATE
    pthread
    fmt::fmt-header-only
    Catch2::Catch2WithMain
)